package com.ruoyi.ftrl.controller;

import java.math.BigDecimal;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Base64;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ftrl.domain.TemperatureInfo;
import com.ruoyi.ftrl.service.ITemperatureInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 室温采集数据信息Controller
 * 
 * @author dihang
 * @date 2024-07-10
 */
@RestController
@RequestMapping("/ftrl/equipments")
public class TemperatureInfoController extends BaseController
{
    @Autowired
    private ITemperatureInfoService temperatureInfoService;

    @PostMapping("ftrl/equipments")
    public void receiveData(@RequestBody String payload) {
        // 给定的包含JSON数据的字符串
//      payload = "Received data: {\"upPacketSN\":-1,\"upDataSN\":-1,\"topic\":\"v1/up/ad\",\"timestamp\":1720146587538,\"tenantId\":\"2000499359\",\"serviceId\":\"\",\"protocol\":\"lwm2m\",\"productId\":\"17106951\",\"payload\":{\"APPdata\":\"AADk/v7+aEaUVHNZIDJhgdSQIAEAAEAnAAAAAEAnAAAAAFkRAAAAAAAAAAAAAAA4KRAFByQJAAAAAEMnAAAAZicAAACXJwAAAJUnAAAAlScAAACVJwAAAJUnAAAAlCcAAACJJwAAAIcnAAAAhycAAACGJwAAAIUnAAAAeCcAAABnJwAAADcnAAAAlyYAAAASJwAAAIUmAAAAkSUAAACRJQAAAJElAAAAkSUAAACRJQAAAEkmADwAPAA8PAATABMAAAAAAAEIAJMEciZgISMRhomUVHNZIDJhCAAALQMOAAEA//8uvpUW\"},\"messageType\":\"dataReport\",\"deviceType\":\"\",\"deviceId\":\"78d20a8165c946a281f5a9507bcb78de\",\"assocAssetId\":\"\",\"IMSI\":\"undefined\",\"IMEI\":\"861322059735494\"}";
        // 处理设备上传的数据，这里payload是接收到的原始密文数据
        System.out.println("Received data: " + payload);
//        String jsonString =payload;
        // 去掉前缀 "Received data: "来得到有效的JSON字符串
        String jsonSubstring = payload.substring(payload.indexOf("{"));

        try {
            // 创建ObjectMapper实例
            ObjectMapper mapper = new ObjectMapper();

            // 解析JSON字符串到JsonNode对象
            JsonNode rootNode = mapper.readTree(jsonSubstring);

            // 获取"payload"对象
            JsonNode payloadNode = rootNode.path("payload");

            // 提取"APPdata"字段的值
            String appDataBase64 = payloadNode.path("APPdata").asText();
            System.out.println("密文数据为："+appDataBase64);

            // 对Base64编码字符串进行解码
            byte[] decodedBytes = Base64.getDecoder().decode(appDataBase64);

            // 将解码后的字节数组转换为16进制字符串
            StringBuilder hexString = new StringBuilder();
            for (byte b : decodedBytes) {
                hexString.append(String.format("%02X", b));
            }
            //该字符串为解密后的16进制编码
            String s = hexString.toString();

            // 输出解码后的16进制字符串
            System.out.println("解码后的16进制字符串: " + hexString.toString());
            //创建对象
            TemperatureInfo temperatureInfo=new TemperatureInfo();
            // 输出解码后的16进制字符串
            //解码规则
//            System.out.println("解码后的16进制字符串: " + hexString.toString());
            String string = hexString.toString();
            String s0 = string.substring(14, 16) + string.substring(12, 14);
            System.out.println("仪表类型为："+s0);
            temperatureInfo.setMeterType(s0);

            String s1 = string.substring(24,26)+string.substring(22, 24) + string.substring(20, 22) + string.substring(18, 20) + string.substring(16, 18);
            System.out.println("仪表编号为："+s1);
            temperatureInfo.setMeterCode(s1);

            String s3 =string.substring(28,30)+ string.substring(26, 28);
            System.out.println("厂家代码为："+s3);
            temperatureInfo.setManufactorCode(s3);

            String s4=string.substring(46,48)+"."+ string.substring(44, 46);
            if (string.charAt(46) == '0'){
                s4=s4.substring(1,5);
            }
            BigDecimal bigDecimalValue = new BigDecimal(s4);
            System.out.println("当前室内温度为："+s4+"℃");
            temperatureInfo.setTemperature(bigDecimalValue);

            String s5=string.substring(50,52)+"."+ string.substring(48, 50);
            if (string.charAt(50) == '0'){
                s5=s5.substring(1,5);
            }
            System.out.println("电池电压为："+s5);
            BigDecimal bigDecimal=new BigDecimal(s5);
            temperatureInfo.setVoltage(bigDecimal);

            String s6=string.substring(58,60)+"."+ string.substring(56, 58);
            if (string.charAt(58) == '0'){
                s6=s6.substring(1,5);
            }
            System.out.println("当前室内温度(重复)为："+s6+"℃");
            BigDecimal bigDecimal1 = new BigDecimal(s6);
            temperatureInfo.setTemperature1(bigDecimal1);

            String s7=string.substring(74,76)+string.substring(72,74)+string.substring(70,72)+ string.substring(68, 70);
            s7=s7.replaceAll("^0+", "");
            System.out.println("累积上电时间为："+s7+"分钟");
            temperatureInfo.setPowerOn(s7);

            String s8=string.substring(92,94);
            s8=String.valueOf(Integer.parseInt(s8, 16));
            System.out.println("当前室内湿度为："+s8);
            temperatureInfo.setHumidity(s8);

            String s9=string.substring(104,106)+ string.substring(102, 104)+string.substring(100,102)+string.substring(98,100)+string.substring(96,98)+string.substring(94,96);
            // 解析字符串为 LocalDateTime 对象
            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyMMddHHmmss");
            LocalDateTime dateTime = LocalDateTime.parse(s9, formatter);
            // 格式化为指定的时间字符串
            DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
            s9 = dateTime.format(outputFormatter);
            System.out.println("实际时间为："+s9);
            Instant instant = dateTime.atZone(ZoneId.systemDefault()).toInstant();
            // 转换为 Date
            Date date = Date.from(instant);
            temperatureInfo.setTime(date);

            String s10=string.substring(106,108);
            s10=s10.replaceAll("^0+", "");
            System.out.println("上一次信号强度为："+s10);
            temperatureInfo.setSignalIntensity(s10);

            String s11= string.substring(110, 112)+string.substring(108,110);
            System.out.println("ST状态为："+s11);
            temperatureInfo.setStState(s11);

            String s12=string.substring(118,120)+"."+ string.substring(116, 118);
            System.out.println("前0-1小时室内平均温度为："+s12+"℃");
            BigDecimal decimal1 = new BigDecimal(s12);
            temperatureInfo.setOneHeat(decimal1);

            String s13=string.substring(120,122);
            s13=String.valueOf(Integer.parseInt(s13, 16));
            System.out.println("前0-1小时湿度为："+s13);
            temperatureInfo.setOneHumidity(s13);

            String s14=string.substring(128,130)+"."+ string.substring(126, 128);
            System.out.println("前1-2小时室内平均温度为："+s14+"℃");
            BigDecimal bigDecimal2 =new BigDecimal(s14);
            temperatureInfo.setTwoHeat(bigDecimal2);

            String s15=string.substring(130,132);
            s15=String.valueOf(Integer.parseInt(s15, 16));
            System.out.println("前1-2小时湿度为："+s15);
            temperatureInfo.setTwoHumidity(s15);

            String s16=string.substring(138,140)+"."+ string.substring(136, 138);
            System.out.println("前2-3小时室内平均温度为："+s16+"℃");
            BigDecimal bigDecimal3 = new BigDecimal(s16);
            temperatureInfo.setThreeHeat(bigDecimal3);

            String s17=string.substring(142,144);
            s17=String.valueOf(Integer.parseInt(s17, 16));
            System.out.println("前2-3小时湿度为："+s17);
            temperatureInfo.setThreeHumidity(s17);

            String s18 = string.substring(148,150) + "." + string.substring(146, 148);
            System.out.println("前3-4小时室内平均温度为：" + s18 + "℃");
            BigDecimal bigDecimal4 = new BigDecimal(s18);
            temperatureInfo.setFourHeat(bigDecimal4);

            String s19 = string.substring(150,152);
            s19 = String.valueOf(Integer.parseInt(s19, 16));
            System.out.println("前3-4小时湿度为：" + s19);
            temperatureInfo.setFourHumidity(s19);

            String s20 = string.substring(158,160) + "." + string.substring(156, 158);
            System.out.println("前4-5小时室内平均温度为：" + s20 + "℃");
            BigDecimal bigDecimal5 = new BigDecimal(s20);
            temperatureInfo.setFiveHeat(bigDecimal5);

            String s21 = string.substring(160,162);
            s21 = String.valueOf(Integer.parseInt(s21, 16));
            System.out.println("前4-5小时湿度为：" + s21);
            temperatureInfo.setFiveHumidity(s21);

            String s22 = string.substring(168,170) + "." + string.substring(166, 168);
            System.out.println("前5-6小时室内平均温度为：" + s22 + "℃");
            BigDecimal bigDecimal6 = new BigDecimal(s22);
            temperatureInfo.setSixHeat(bigDecimal6);

            String s23 = string.substring(170,172);
            s23 = String.valueOf(Integer.parseInt(s23, 16));
            System.out.println("前5-6小时湿度为：" + s23);
            temperatureInfo.setSixHumidity(s23);

            String s24 = string.substring(178,180) + "." + string.substring(176, 178);
            System.out.println("前6-7小时室内平均温度为：" + s24 + "℃");
            BigDecimal bigDecimal7 = new BigDecimal(s24);
            temperatureInfo.setSevenHeat(bigDecimal7);

            String s25 = string.substring(180,182);
            s25 = String.valueOf(Integer.parseInt(s25, 16));
            System.out.println("前6-7小时湿度为：" + s25);
            temperatureInfo.setSevenHumidity(s25);

            String s26 = string.substring(188,190) + "." + string.substring(186, 188);
            System.out.println("前7-8小时室内平均温度为：" + s26 + "℃");
            BigDecimal bigDecimal8 = new BigDecimal(s26);
            temperatureInfo.setEightHeat(bigDecimal8);

            String s27 = string.substring(190,192);
            s27 = String.valueOf(Integer.parseInt(s27, 16));
            System.out.println("前7-8小时湿度为：" + s27);
            temperatureInfo.setEightHumidity(s27);

            String s28 = string.substring(198,200) + "." + string.substring(196, 198);
            System.out.println("前8-9小时室内平均温度为：" + s28 + "℃");
            BigDecimal bigDecimal9 = new BigDecimal(s28);
            temperatureInfo.setNineHeat(bigDecimal9);

            String s29 = string.substring(200,202);
            s29 = String.valueOf(Integer.parseInt(s29, 16));
            System.out.println("前8-9小时湿度为：" + s29);
            temperatureInfo.setNineHumidity(s29);

            String s30 = string.substring(208,210) + "." + string.substring(206, 208);
            System.out.println("前9-10小时室内平均温度为：" + s30 + "℃");
            BigDecimal bigDecimal10 = new BigDecimal(s30);
            temperatureInfo.setTenHeat(bigDecimal10);

            String s31 = string.substring(210,212);
            s31 = String.valueOf(Integer.parseInt(s31, 16));
            System.out.println("前9-10小时湿度为：" + s31);
            temperatureInfo.setTenHumidity(s31);

            String s32 = string.substring(218,220) + "." + string.substring(216, 218);
            System.out.println("前10-11小时室内平均温度为：" + s32 + "℃");
            BigDecimal bigDecimal11 = new BigDecimal(s32);
            temperatureInfo.setElevenHeat(bigDecimal11);

            String s33 = string.substring(220,222);
            s33 = String.valueOf(Integer.parseInt(s33, 16));
            System.out.println("前10-11小时湿度为：" + s33);
            temperatureInfo.setElevenHumidity(s33);

            String s34 = string.substring(228,230) + "." + string.substring(226, 228);
            System.out.println("前11-12小时室内平均温度为：" + s34 + "℃");
            BigDecimal bigDecimal12 = new BigDecimal(s34);
            temperatureInfo.setTwelveHeat(bigDecimal12);

            String s35 = string.substring(230,232);
            s35 = String.valueOf(Integer.parseInt(s35, 16));
            System.out.println("前11-12小时湿度为：" + s35);
            temperatureInfo.setTwelveHumidity(s35);

            String s36 = string.substring(238,240) + "." + string.substring(236, 238);
            System.out.println("前12-13小时室内平均温度为：" + s36 + "℃");
            BigDecimal bigDecimal13 = new BigDecimal(s36);
            temperatureInfo.setThirteenHeat(bigDecimal13);

            String s37 = string.substring(240,242);
            s37 = String.valueOf(Integer.parseInt(s37, 16));
            System.out.println("前12-13小时湿度为：" + s37);
            temperatureInfo.setThirteenHumidity(s37);

            String s38 = string.substring(248,250) + "." + string.substring(246, 248);
            System.out.println("前13-14小时室内平均温度为：" + s38 + "℃");
            BigDecimal bigDecimal14 = new BigDecimal(s38);
            temperatureInfo.setFourteenHeat(bigDecimal14);

            String s39 = string.substring(250,252);
            s39 = String.valueOf(Integer.parseInt(s39, 16));
            System.out.println("前13-14小时湿度为：" + s39);
            temperatureInfo.setFourteenHumidity(s39);

            String s40 = string.substring(258,260) + "." + string.substring(256, 258);
            System.out.println("前14-15小时室内平均温度为：" + s40 + "℃");
            BigDecimal bigDecimal15 = new BigDecimal(s40);
            temperatureInfo.setFifteenHeat(bigDecimal15);

            String s41 = string.substring(260,262);
            s41 = String.valueOf(Integer.parseInt(s41, 16));
            System.out.println("前14-15小时湿度为：" + s41);
            temperatureInfo.setFifteenHumidity(s41);

            String s42 = string.substring(268,270) + "." + string.substring(266, 268);
            System.out.println("前15-16小时室内平均温度为：" + s42 + "℃");
            BigDecimal bigDecimal16 = new BigDecimal(s42);
            temperatureInfo.setSixteenHeat(bigDecimal16);

            String s43 = string.substring(270,272);
            s43 = String.valueOf(Integer.parseInt(s43, 16));
            System.out.println("前15-16小时湿度为：" + s43);
            temperatureInfo.setSixteenHumidity(s43);

            String s44 = string.substring(278,280) + "." + string.substring(276, 278);
            System.out.println("前16-17小时室内平均温度为：" + s44 + "℃");
            BigDecimal bigDecimal17 = new BigDecimal(s44);
            temperatureInfo.setSeventeenHeat(bigDecimal17);

            String s45 = string.substring(280,282);
            s45 = String.valueOf(Integer.parseInt(s45, 16));
            System.out.println("前16-17小时湿度为：" + s45);
            temperatureInfo.setSeventeenHumidity(s45);

            String s46 = string.substring(288,290) + "." + string.substring(286, 288);
            System.out.println("前17-18小时室内平均温度为：" + s46 + "℃");
            BigDecimal bigDecimal18 = new BigDecimal(s46);
            temperatureInfo.setEighteenHeat(bigDecimal18);

            String s47 = string.substring(290,292);
            s47 = String.valueOf(Integer.parseInt(s47, 16));
            System.out.println("前17-18小时湿度为：" + s47);
            temperatureInfo.setEighteenHumidity(s47);

            String s48 = string.substring(298,300) + "." + string.substring(296, 298);
            System.out.println("前18-19小时室内平均温度为：" + s48 + "℃");
            BigDecimal bigDecimal19 = new BigDecimal(s48);
            temperatureInfo.setNineteenHeata(bigDecimal19);

            String s49 = string.substring(300,302);
            s49 = String.valueOf(Integer.parseInt(s49, 16));
            System.out.println("前18-19小时湿度为：" + s49);
            temperatureInfo.setNineteenHumidity(s49);

            String s50 = string.substring(308,310) + "." + string.substring(306, 308);
            System.out.println("前19-20小时室内平均温度为：" + s50 + "℃");
            BigDecimal bigDecimal20 = new BigDecimal(s50);
            temperatureInfo.setTwentyHeat(bigDecimal20);

            String s51 = string.substring(310,312);
            s51 = String.valueOf(Integer.parseInt(s51, 16));
            System.out.println("前19-20小时湿度为：" + s51);
            temperatureInfo.setTwentyHumidity(s51);

            String s52 = string.substring(318,320) + "." + string.substring(316, 318);
            System.out.println("前20-21小时室内平均温度为：" + s52 + "℃");
            BigDecimal bigDecimal21 = new BigDecimal(s52);
            temperatureInfo.setTwentyOneHeat(bigDecimal21);

            String s53 = string.substring(320,322);
            s53 = String.valueOf(Integer.parseInt(s53, 16));
            System.out.println("前20-21小时湿度为：" + s53);
            temperatureInfo.setTwentyOneHumidity(s53);

            String s54 = string.substring(328,330) + "." + string.substring(326, 328);
            System.out.println("前21-22小时室内平均温度为：" + s54 + "℃");
            BigDecimal bigDecimal22 = new BigDecimal(s54);
            temperatureInfo.setTwentyTwoHeat(bigDecimal22);

            String s55 = string.substring(330,332);
            s55 = String.valueOf(Integer.parseInt(s55, 16));
            System.out.println("前21-22小时湿度为：" + s55);
            temperatureInfo.setTwentyTwoHumidity(s55);

            String s56 = string.substring(338,340) + "." + string.substring(336, 338);
            System.out.println("前22-23小时室内平均温度为：" + s56 + "℃");
            BigDecimal bigDecimal23 = new BigDecimal(s56);
            temperatureInfo.setTwentyThreeHeat(bigDecimal23);

            String s57 = string.substring(340,342);
            s57 = String.valueOf(Integer.parseInt(s57, 16));
            System.out.println("前22-23小时湿度为：" + s57);
            temperatureInfo.setTwentyThreeHumidity(s57);

            String s58 = string.substring(348,350) + "." + string.substring(346, 348);
            System.out.println("前23-24小时室内平均温度为：" + s58 + "℃");
            BigDecimal bigDecimal24 = new BigDecimal(s58);
            temperatureInfo.setTwentyFourHeat(bigDecimal24);

            String s59 = string.substring(350,352);
            s59 = String.valueOf(Integer.parseInt(s59, 16));
            System.out.println("前23-24小时湿度为：" + s59);
            temperatureInfo.setTwentyFourHumidity(s59);

            String s60 = string.substring(358,360) + "." + string.substring(356, 358);
            System.out.println("前1日0-24小时室内平均温度为：" + s60 + "℃");
            BigDecimal bigDecimal25 = new BigDecimal(s60);
            temperatureInfo.setDayHeat(bigDecimal25);

            String s61 = string.substring(360,362);
            s61 = String.valueOf(Integer.parseInt(s61, 16));
            System.out.println("前1日0-24小时平均湿度为：" + s61);
            temperatureInfo.setDayHumidity(s61);

            String s62 = string.substring(364, 366) + string.substring(362, 364);
            s62=String.valueOf(Integer.parseInt(s62, 16));
            System.out.println("上报时间间隔（分钟）为："+s62+"分钟");
            temperatureInfo.setReportingInterval(s62);

            String s63 = string.substring(368, 370) + string.substring(366, 368);
            s63=String.valueOf(Integer.parseInt(s63, 16));
            System.out.println("上传延时（分钟）为："+s63+"分钟");
            temperatureInfo.setUploadBranch(s63);

            String s64 = string.substring(370, 372);
            s64=String.valueOf(Integer.parseInt(s64, 16));
            System.out.println("上传延时（秒）为："+s64+"秒");
            temperatureInfo.setUploadSecond(s64);

            String s65 = string.substring(378, 380)+string.substring(376,378);
            s65=String.valueOf(Integer.parseInt(s65, 16));
            System.out.println("上传总次数为："+s65+"次");
            temperatureInfo.setUploadCount(s65);

            String s66 = string.substring(382, 384)+string.substring(380,382);
            s66=String.valueOf(Integer.parseInt(s66, 16));
            System.out.println("成功次数为："+s66+"次");
            temperatureInfo.setSuccesCount(s66);

            String s67 = string.substring(386, 388)+string.substring(384,386);
            s67=String.valueOf(Integer.parseInt(s67, 16));
            int number = Integer.parseInt(s67);
            double result = (double) number / 100;
            s67=String .valueOf(result);
            System.out.println("温度修正参数为："+s67);
            temperatureInfo.setTemperatureCorrection(s67);

            String s68 = string.substring(390, 392)+string.substring(388,390);
            s68=String.valueOf(Integer.parseInt(s68, 16));
            s68=String.valueOf(Integer.parseInt(s68, 16));
            int num = Integer.parseInt(s68);
            double res = (double) num / 100;
            s68=String .valueOf(res);
            System.out.println("湿度修正参数为："+s68);
            temperatureInfo.setHumidityCorrection(s68);

            String s69 = string.substring(392, 394);
            System.out.println("数据有效性为："+s69);
            temperatureInfo.setIsValid(s69);

            String s70 = string.substring(394, 396);
            s70=String.valueOf(Integer.parseInt(s70, 16));
            System.out.println("信号强度为："+s70);
            temperatureInfo.setSignals(s70);

            String s71 = string.substring(396, 398);
            System.out.println("运营商类型为："+s71);
            temperatureInfo.setOperatorsType(s71);

            String s72 = string.substring(416, 418)+string.substring(414,416)+string.substring(412,414)+string.substring(410,412)
                    +string.substring(408,410)+string.substring(406,408)+string.substring(404,406)+string.substring(402,404)
                    +string.substring(400,402)+string.substring(398,400);
            System.out.println("SIM卡的ICCID为："+s72);
            temperatureInfo.setICCID(s72);

            String s73 = string.substring(436, 438)+string.substring(434,436)+string.substring(432,434)+string.substring(430,432)
                    +string.substring(428,430)+string.substring(426,428)+string.substring(424,426)+string.substring(422,424)
                    +string.substring(420,422)+string.substring(418,420);
            s73=s73.replaceAll("^0+", "");
            System.out.println("模组的IMEI为："+s73);
            temperatureInfo.setIMEI(s73);

            String s74=string.substring(440,442)+string.substring(438,440);
            s74=String.valueOf(Integer.parseInt(s74, 16));
            System.out.println("上传数据区块除去状态字的协议版本为："+s74);
            temperatureInfo.setVersion(s74);

            String s75=string.substring(444,446)+string.substring(442,444);
            s75=String.valueOf(Integer.parseInt(s75, 16));
            System.out.println("上传数据区块状态字的协议版本为："+s75);
            temperatureInfo.setVersionState(s75);

            String s76=string.substring(448,450)+string.substring(446,448);
            s76=String.valueOf(Integer.parseInt(s76, 16));
            int numbers = Integer.parseInt(s76);
            s76 = String.format("%02d", numbers);
            System.out.println("上传参数区块的类型为："+s76);
            temperatureInfo.setType(s76);

            String s77=string.substring(450,452)+string.substring(452,454);
            System.out.println("上传参数区块的特征符号为："+s77);
            temperatureInfo.setFeatures(s77);

            String s78=string.substring(454,456);
            s78=String.valueOf(Integer.parseInt(s78, 16));
            System.out.println("上传参数区块的长度为："+s78+"u");
            temperatureInfo.setLength(s78);

            String s79=string.substring(456,458);
            s79=String.valueOf(Integer.parseInt(s79, 16));
            System.out.println("上传参数区块的校验码为："+s79);
            temperatureInfo.setVerificationCode(s79);
            //将读取到的数据入库
            temperatureInfoService.insertTemperatureInfo(temperatureInfo);
        } catch (Exception e) {
            e.printStackTrace();
            System.err.println("Failed to parse JSON or decode Base64.");
        }


        // TODO: 你可以在这里解析payload并进行实际的业务处理，如保存到数据库等
    }


    /**
     * 查询室温采集数据信息列表
     */
    @PreAuthorize("@ss.hasPermi('ftrl:equipment:list')")
    @GetMapping("/list")
    public TableDataInfo list(TemperatureInfo temperatureInfo)
    {
        startPage();
        List<TemperatureInfo> list = temperatureInfoService.selectTemperatureInfoList(temperatureInfo);
        return getDataTable(list);
    }

    /**
     * 导出室温采集数据信息列表
     */
    @PreAuthorize("@ss.hasPermi('ftrl:equipment:export')")
    @Log(title = "室温采集数据信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TemperatureInfo temperatureInfo)
    {
        List<TemperatureInfo> list = temperatureInfoService.selectTemperatureInfoList(temperatureInfo);
        ExcelUtil<TemperatureInfo> util = new ExcelUtil<TemperatureInfo>(TemperatureInfo.class);
        util.exportExcel(response, list, "室温采集数据信息数据");
    }

    /**
     * 获取室温采集数据信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('ftrl:equipment:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(temperatureInfoService.selectTemperatureInfoById(id));
    }

    /**
     * 新增室温采集数据信息
     */
    @PreAuthorize("@ss.hasPermi('ftrl:equipment:add')")
    @Log(title = "室温采集数据信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TemperatureInfo temperatureInfo)
    {
        return toAjax(temperatureInfoService.insertTemperatureInfo(temperatureInfo));
    }

    /**
     * 修改室温采集数据信息
     */
    @PreAuthorize("@ss.hasPermi('ftrl:equipment:edit')")
    @Log(title = "室温采集数据信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TemperatureInfo temperatureInfo)
    {
        return toAjax(temperatureInfoService.updateTemperatureInfo(temperatureInfo));
    }

    /**
     * 删除室温采集数据信息
     */
    @PreAuthorize("@ss.hasPermi('ftrl:equipment:remove')")
    @Log(title = "室温采集数据信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(temperatureInfoService.deleteTemperatureInfoByIds(ids));
    }

    public static void main(String[] args) {
//        String payload = "{\"upPacketSN\":-1,\"upDataSN\":-1,\"topic\":\"v1/up/ad19prof\",\"timestamp\":1727326004831,\"tenantId\":\"2000092468\",\"serviceId\":\"WaterMeter\",\"protocol\":\"lwm2m\",\"profile\":true,\"productId\":\"16998316\",\"payload\":{\"serviceId\":\"WaterMeter\",\"serviceData\":{\"uData\":\"/v7+aEZ3N2hZIDJhgdSQIAEAAGgjAAAAAGgjAAAAAFlgIwAAAAAAAAAAAAA3RhImCSQJAAAAAEgjAAAAFCMAAACRIgAAAIIiAAAAISMAAAASIwAAABAjAAAAEyMAAAATIwAAAFgjAAAAiCMAAACIIwAAAIYjAAAAlSMAAAAHJAAAAAkkAAAAJyQAAABDJAAAAFAkAAAARCQAAABBJAAAADQkAAAAISQAAAAAJAAAAAIkADwAPAA8PABeDyIPAAAAAAEHABSXFiAAIyMRhol3N2hZIDJhCAAALQMOAAEA//8uRN4W\"}},\"messageType\":\"dataReport\",\"deviceType\":\"205aa9aa83c94f3a8c720e65fffe646e\",\"assocAssetId\":\"\",\"IMSI\":\"undefined\",\"IMEI\":\"861322059683777\"}";
//        String payload = "{\"upPacketSN\":-1,\"upDataSN\":-1,\"topic\":\"v1/up/ad19prof\",\"timestamp\":1727435767362,\"tenantId\":\"2000092468\",\"serviceId\":\"WaterMeter\",\"protocol\":\"lwm2m\",\"profile\":true,\"productId\":\"16998316\",\"payload\":{\"serviceId\":\"WaterMeter\",\"serviceData\":{\"uData\":\"/v7+aEZmYmlZIDJhgdSQIAEAAJElAAAAAJElAAAAAHmXBwAAAAAAAAAAAABXFRknCSQUAAAAAJElAAAAkSUAAACTJQAAAJYlAAAAkSUAAACEJQAAAGUlAAAASCUAAAA0JQAAABklAAAAEyUAAAAjJQAAABklAAAAGCUAAAAZJQAAACclAAAAMyUAAABBJQAAAFAlAAAAUyUAAABkJQAAAHQlAAAAgCUAAAB0JQAAAGElADwAPAA8PAAyBf0EAAAAAAELAEWQFiAAIyMRholmYmlZIDJhCAAALQMOAAEA//8uJ78W\"}},\"messageType\":\"dataReport\",\"deviceType\":\"\",\"deviceId\":\"40f15598d1e048aa9d09aa9489b810e9\",\"assocAssetId\":\"\",\"IMSI\":\"undefined\",\"IMEI\":\"861322059696266\"}";
        String payload = " {\"upPacketSN\":-1,\"upDataSN\":-1,\"topic\":\"v1/up/ad19prof\",\"timestamp\":1727436877253,\"tenantId\":\"2000092468\",\"serviceId\":\"WaterMeter\",\"protocol\":\"lwm2m\",\"profile\":true,\"productId\":\"16998316\",\"payload\":{\"serviceId\":\"WaterMeter\",\"serviceData\":{\"uData\":\"/v7+aEZzFWhZIDJhgdSQIAEAAIQkAAAAAIQkAAAAAJIlFwAAAAAAAAAAAAAiNBknCSQSAAAAAAclAAAAByUAAAAQJQAAABIlAAAAEiUAAAAJJQAAAIEkAAAAQyQAAAAFJAAAAGUjAAAAVyMAAACFIwAAAJAjAAAAiCMAAACHIwAAAJAjAAAAmCMAAAARJAAAACAkAAAAJyQAAAA3JAAAAEIkAAAANyQAAAAzJAAAACQkADwAPAA8PAA9C+gKAAAAAAENABeUFiAAIyMRholzFWhZIDJhCAAALQMOAAEA//8uwE4W\"}},\"messageType\":\"dataReport\",\"deviceType\":\"\",\"deviceId\":\"208fb1faa9d0478b89c2c23d329f4cb9\",\"assocAssetId\":\"\",\"IMSI\":\"undefined\",\"IMEI\":\"861322059681573\"}";
//            String payload=" {\"upPacketSN\":-1,\"upDataSN\":-1,\"topic\":\"v1/up/ad19prof\",\"timestamp\":1727588667405,\"tenantId\":\"2000092468\",\"serviceId\":\"\",\"protocol\":\"lwm2m\",\"productId\":\"16998316\",\"payload\":[{\"serviceId\":\"WaterMeter\",\"serviceData\":{\"uData\":\"/v7+aEY2N2hZIDJhgdSQIAEAABEmAAAAABEmAAAAADgEJAAAAAAAAAAAAAAJRBMpCSQJAAAAAAkmAAAAEiYAAAABJgAAAJglAAAAFSYAAAB2JgAAABknAAAAGCcAAAAYJwAAACknAAAANycAAABAJwAAADgnAAAAOScAAAAzJwAAABInAAAAFiYAAAAQJgAAAIglAAAABCYAAAAjJgAAACMmAAAAIyYAAAAjJgAAADEmADwAPAA8PACnD1UPAAAAAAEJAGKYFiAAIyMRhok2N2hZIDJhCAAALQMOAAEA//8u0PsW\"}}],\"messageType\":\"dataReportTupUnion\",\"deviceType\":\"\",\"deviceId\":\"d2d445f703c8456c83ea748541c7ffbe\",\"assocAssetId\":\"\",\"IMSI\":\"undefined\",\"IMEI\":\"861322059683736\"}";
        // 处理设备上传的数据，这里payload是接收到的原始密文数据
        System.out.println("Received data: " + payload);
//        String jsonString =payload;
        // 去掉前缀 "Received data: "来得到有效的JSON字符串
//        String jsonSubstring = payload.substring(payload.indexOf("{"));
//
//        try {
//            // 创建ObjectMapper实例
//            ObjectMapper mapper = new ObjectMapper();
//
//            // 解析JSON字符串到JsonNode对象
//            JsonNode rootNode = mapper.readTree(jsonSubstring);
//
//            // 获取"payload"对象
//            JsonNode payloadNode = rootNode.path("payload");
//
//            // 提取"APPdata"字段的值
//            JsonNode serviceDataNode = rootNode.path("payload").path("serviceData");
//            String appDataBase64 = serviceDataNode.path("uData").asText();
//            System.out.println("密文数据为："+appDataBase64);
//
//            // 对Base64编码字符串进行解码
//            byte[] decodedBytes = Base64.getDecoder().decode(appDataBase64);
//
//            // 将解码后的字节数组转换为16进制字符串
//            StringBuilder hexString = new StringBuilder();
//            for (byte b : decodedBytes) {
//                hexString.append(String.format("%02X", b));
//            }
//            //该字符串为解密后的16进制编码
//            String s = hexString.toString();
//
//            // 输出解码后的16进制字符串
//            System.out.println("解码后的16进制字符串: " + hexString.toString());
        StringBuilder hexString = new StringBuilder();
        try {
            // 创建 ObjectMapper 实例
            ObjectMapper mapper = new ObjectMapper();

            // 解析 JSON 字符串到 JsonNode 对象
            JsonNode rootNode = mapper.readTree(payload);

            String imei = rootNode.path("IMEI").asText();
            System.out.println("IMEI: " + imei);

            // 获取 "payload" 节点
            JsonNode payloadNode = rootNode.path("payload");

            // 检查 payload 是对象还是数组
            if (payloadNode.isObject()) {
                // 处理对象类型的 payload
                JsonNode serviceDataNode = payloadNode.path("serviceData");
                String appDataBase64 = serviceDataNode.path("uData").asText(null);

                if (appDataBase64 == null || appDataBase64.isEmpty()) {
                    System.err.println("uData 字段为空或丢失");
                }

                System.out.println("密文数据为：" + appDataBase64);

                // 对 Base64 编码字符串进行解码
                try {
                    byte[] decodedBytes = Base64.getDecoder().decode(appDataBase64);

                    // 将解码后的字节数组转换为16进制字符串
//                    StringBuilder hexString = new StringBuilder();
                    for (byte b : decodedBytes) {
                        hexString.append(String.format("%02X", b));
                    }

                    // 输出解码后的16进制字符串
                    System.out.println("解码后的16进制字符串: " + hexString.toString());
                } catch (IllegalArgumentException e) {
                    System.err.println("Base64 解码失败: " + e.getMessage());
                }
            } else if (payloadNode.isArray()) {
                // 处理数组类型的 payload
                for (JsonNode node : payloadNode) {
                    JsonNode serviceDataNode = node.path("serviceData");
                    String appDataBase64 = serviceDataNode.path("uData").asText(null);

                    if (appDataBase64 == null || appDataBase64.isEmpty()) {
                        System.err.println("uData 字段为空或丢失");
                        continue;
                    }

                    System.out.println("密文数据为：" + appDataBase64);

                    // 对 Base64 编码字符串进行解码
                    try {
                        byte[] decodedBytes = Base64.getDecoder().decode(appDataBase64);

                        // 将解码后的字节数组转换为16进制字符串

                        for (byte b : decodedBytes) {
                            hexString.append(String.format("%02X", b));
                        }

                        // 输出解码后的16进制字符串
                        System.out.println("解码后的16进制字符串: " + hexString.toString());
                    } catch (IllegalArgumentException e) {
                        System.err.println("Base64 解码失败: " + e.getMessage());
                    }
                }
            } else {
                System.err.println("Unexpected payload structure.");
            }
        } catch (Exception e) {
            System.err.println("Failed to parse JSON or decode Base64.");
            e.printStackTrace();
        }


        //创建对象
            TemperatureInfo temperatureInfo=new TemperatureInfo();
            // 输出解码后的16进制字符串
            //解码规则
//            System.out.println("解码后的16进制字符串: " + hexString.toString());
            String string = hexString.toString();

            String s0 = string.substring(6, 8) +string.substring(8, 10);
            System.out.println("仪表类型为："+s0);
            temperatureInfo.setMeterType(s0);

//            String s1 = string.substring(24,26)+string.substring(22, 24) + string.substring(20, 22) + string.substring(18, 20) + string.substring(16, 18);
//            System.out.println("仪表编号为："+s1);
//            temperatureInfo.setMeterCode(s1);
//
//            String s3 =string.substring(28,30)+ string.substring(26, 28);
//            System.out.println("厂家代码为："+s3);
//            temperatureInfo.setManufactorCode(s3);
//
//            String s4=string.substring(46,48)+"."+ string.substring(44, 46);
//            if (string.charAt(46) == '0'){
//                s4=s4.substring(1,5);
//            }
//            BigDecimal bigDecimalValue = new BigDecimal(s4);
//            System.out.println("当前室内温度为："+s4+"℃");
//            temperatureInfo.setTemperature(bigDecimalValue);
//
//            String s5=string.substring(50,52)+"."+ string.substring(48, 50);
//            if (string.charAt(50) == '0'){
//                s5=s5.substring(1,5);
//            }
//            System.out.println("电池电压为："+s5);
//            BigDecimal bigDecimal=new BigDecimal(s5);
//            temperatureInfo.setVoltage(bigDecimal);
//
//            String s6=string.substring(58,60)+"."+ string.substring(56, 58);
//            if (string.charAt(58) == '0'){
//                s6=s6.substring(1,5);
//            }
//            System.out.println("当前室内温度(重复)为："+s6+"℃");
//            BigDecimal bigDecimal1 = new BigDecimal(s6);
//            temperatureInfo.setTemperature1(bigDecimal1);
//
//            String s7=string.substring(74,76)+string.substring(72,74)+string.substring(70,72)+ string.substring(68, 70);
//            s7=s7.replaceAll("^0+", "");
//            System.out.println("累积上电时间为："+s7+"分钟");
//            temperatureInfo.setPowerOn(s7);
//
//            String s8=string.substring(92,94);
//            s8=String.valueOf(Integer.parseInt(s8, 16));
//            System.out.println("当前室内湿度为："+s8);
//            temperatureInfo.setHumidity(s8);
//
////            String s9=string.substring(104,106)+ string.substring(102, 104)+string.substring(100,102)+string.substring(98,100)+string.substring(96,98)+string.substring(94,96);
////            // 解析字符串为 LocalDateTime 对象
////            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyMMddHHmmss");
////            LocalDateTime dateTime = LocalDateTime.parse(s9, formatter);
////            // 格式化为指定的时间字符串
////            DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
////            s9 = dateTime.format(outputFormatter);
////            System.out.println("实际时间为："+s9);
////            Instant instant = dateTime.atZone(ZoneId.systemDefault()).toInstant();
////            // 转换为 Date
////            Date date = Date.from(instant);
////            temperatureInfo.setTime(date);
//
//            String s10=string.substring(106,108);
//            s10=s10.replaceAll("^0+", "");
//            System.out.println("上一次信号强度为："+s10);
//            temperatureInfo.setSignalIntensity(s10);
//
//            String s11= string.substring(110, 112)+string.substring(108,110);
//            System.out.println("ST状态为："+s11);
//            temperatureInfo.setStState(s11);
//
//            String s12=string.substring(118,120)+"."+ string.substring(116, 118);
//            System.out.println("前0-1小时室内平均温度为："+s12+"℃");
//            BigDecimal decimal1 = new BigDecimal(s12);
//            temperatureInfo.setOneHeat(decimal1);
//
//            String s13=string.substring(120,122);
//            s13=String.valueOf(Integer.parseInt(s13, 16));
//            System.out.println("前0-1小时湿度为："+s13);
//            temperatureInfo.setOneHumidity(s13);
//
//            String s14=string.substring(128,130)+"."+ string.substring(126, 128);
//            System.out.println("前1-2小时室内平均温度为："+s14+"℃");
//            BigDecimal bigDecimal2 =new BigDecimal(s14);
//            temperatureInfo.setTwoHeat(bigDecimal2);
//
//            String s15=string.substring(130,132);
//            s15=String.valueOf(Integer.parseInt(s15, 16));
//            System.out.println("前1-2小时湿度为："+s15);
//            temperatureInfo.setTwoHumidity(s15);
//
//            String s16=string.substring(138,140)+"."+ string.substring(136, 138);
//            System.out.println("前2-3小时室内平均温度为："+s16+"℃");
//            BigDecimal bigDecimal3 = new BigDecimal(s16);
//            temperatureInfo.setThreeHeat(bigDecimal3);
//
//            String s17=string.substring(142,144);
//            s17=String.valueOf(Integer.parseInt(s17, 16));
//            System.out.println("前2-3小时湿度为："+s17);
//            temperatureInfo.setThreeHumidity(s17);
//
//            String s18 = string.substring(148,150) + "." + string.substring(146, 148);
//            System.out.println("前3-4小时室内平均温度为：" + s18 + "℃");
//            BigDecimal bigDecimal4 = new BigDecimal(s18);
//            temperatureInfo.setFourHeat(bigDecimal4);
//
//            String s19 = string.substring(150,152);
//            s19 = String.valueOf(Integer.parseInt(s19, 16));
//            System.out.println("前3-4小时湿度为：" + s19);
//            temperatureInfo.setFourHumidity(s19);
//
//            String s20 = string.substring(158,160) + "." + string.substring(156, 158);
//            System.out.println("前4-5小时室内平均温度为：" + s20 + "℃");
//            BigDecimal bigDecimal5 = new BigDecimal(s20);
//            temperatureInfo.setFiveHeat(bigDecimal5);
//
//            String s21 = string.substring(160,162);
//            s21 = String.valueOf(Integer.parseInt(s21, 16));
//            System.out.println("前4-5小时湿度为：" + s21);
//            temperatureInfo.setFiveHumidity(s21);
//
//            String s22 = string.substring(168,170) + "." + string.substring(166, 168);
//            System.out.println("前5-6小时室内平均温度为：" + s22 + "℃");
//            BigDecimal bigDecimal6 = new BigDecimal(s22);
//            temperatureInfo.setSixHeat(bigDecimal6);
//
//            String s23 = string.substring(170,172);
//            s23 = String.valueOf(Integer.parseInt(s23, 16));
//            System.out.println("前5-6小时湿度为：" + s23);
//            temperatureInfo.setSixHumidity(s23);
//
//            String s24 = string.substring(178,180) + "." + string.substring(176, 178);
//            System.out.println("前6-7小时室内平均温度为：" + s24 + "℃");
//            BigDecimal bigDecimal7 = new BigDecimal(s24);
//            temperatureInfo.setSevenHeat(bigDecimal7);
//
//            String s25 = string.substring(180,182);
//            s25 = String.valueOf(Integer.parseInt(s25, 16));
//            System.out.println("前6-7小时湿度为：" + s25);
//            temperatureInfo.setSevenHumidity(s25);
//
//            String s26 = string.substring(188,190) + "." + string.substring(186, 188);
//            System.out.println("前7-8小时室内平均温度为：" + s26 + "℃");
//            BigDecimal bigDecimal8 = new BigDecimal(s26);
//            temperatureInfo.setEightHeat(bigDecimal8);
//
//            String s27 = string.substring(190,192);
//            s27 = String.valueOf(Integer.parseInt(s27, 16));
//            System.out.println("前7-8小时湿度为：" + s27);
//            temperatureInfo.setEightHumidity(s27);
//
//            String s28 = string.substring(198,200) + "." + string.substring(196, 198);
//            System.out.println("前8-9小时室内平均温度为：" + s28 + "℃");
//            BigDecimal bigDecimal9 = new BigDecimal(s28);
//            temperatureInfo.setNineHeat(bigDecimal9);
//
//            String s29 = string.substring(200,202);
//            s29 = String.valueOf(Integer.parseInt(s29, 16));
//            System.out.println("前8-9小时湿度为：" + s29);
//            temperatureInfo.setNineHumidity(s29);
//
//            String s30 = string.substring(208,210) + "." + string.substring(206, 208);
//            System.out.println("前9-10小时室内平均温度为：" + s30 + "℃");
//            BigDecimal bigDecimal10 = new BigDecimal(s30);
//            temperatureInfo.setTenHeat(bigDecimal10);
//
//            String s31 = string.substring(210,212);
//            s31 = String.valueOf(Integer.parseInt(s31, 16));
//            System.out.println("前9-10小时湿度为：" + s31);
//            temperatureInfo.setTenHumidity(s31);
//
//            String s32 = string.substring(218,220) + "." + string.substring(216, 218);
//            System.out.println("前10-11小时室内平均温度为：" + s32 + "℃");
//            BigDecimal bigDecimal11 = new BigDecimal(s32);
//            temperatureInfo.setElevenHeat(bigDecimal11);
//
//            String s33 = string.substring(220,222);
//            s33 = String.valueOf(Integer.parseInt(s33, 16));
//            System.out.println("前10-11小时湿度为：" + s33);
//            temperatureInfo.setElevenHumidity(s33);
//
//            String s34 = string.substring(228,230) + "." + string.substring(226, 228);
//            System.out.println("前11-12小时室内平均温度为：" + s34 + "℃");
//            BigDecimal bigDecimal12 = new BigDecimal(s34);
//            temperatureInfo.setTwelveHeat(bigDecimal12);
//
//            String s35 = string.substring(230,232);
//            s35 = String.valueOf(Integer.parseInt(s35, 16));
//            System.out.println("前11-12小时湿度为：" + s35);
//            temperatureInfo.setTwelveHumidity(s35);
//
//            String s36 = string.substring(238,240) + "." + string.substring(236, 238);
//            System.out.println("前12-13小时室内平均温度为：" + s36 + "℃");
//            BigDecimal bigDecimal13 = new BigDecimal(s36);
//            temperatureInfo.setThirteenHeat(bigDecimal13);
//
//            String s37 = string.substring(240,242);
//            s37 = String.valueOf(Integer.parseInt(s37, 16));
//            System.out.println("前12-13小时湿度为：" + s37);
//            temperatureInfo.setThirteenHumidity(s37);
//
//            String s38 = string.substring(248,250) + "." + string.substring(246, 248);
//            System.out.println("前13-14小时室内平均温度为：" + s38 + "℃");
//            BigDecimal bigDecimal14 = new BigDecimal(s38);
//            temperatureInfo.setFourteenHeat(bigDecimal14);
//
//            String s39 = string.substring(250,252);
//            s39 = String.valueOf(Integer.parseInt(s39, 16));
//            System.out.println("前13-14小时湿度为：" + s39);
//            temperatureInfo.setFourteenHumidity(s39);
//
//            String s40 = string.substring(258,260) + "." + string.substring(256, 258);
//            System.out.println("前14-15小时室内平均温度为：" + s40 + "℃");
//            BigDecimal bigDecimal15 = new BigDecimal(s40);
//            temperatureInfo.setFifteenHeat(bigDecimal15);
//
//            String s41 = string.substring(260,262);
//            s41 = String.valueOf(Integer.parseInt(s41, 16));
//            System.out.println("前14-15小时湿度为：" + s41);
//            temperatureInfo.setFifteenHumidity(s41);
//
//            String s42 = string.substring(268,270) + "." + string.substring(266, 268);
//            System.out.println("前15-16小时室内平均温度为：" + s42 + "℃");
//            BigDecimal bigDecimal16 = new BigDecimal(s42);
//            temperatureInfo.setSixteenHeat(bigDecimal16);
//
//            String s43 = string.substring(270,272);
//            s43 = String.valueOf(Integer.parseInt(s43, 16));
//            System.out.println("前15-16小时湿度为：" + s43);
//            temperatureInfo.setSixteenHumidity(s43);
//
//            String s44 = string.substring(278,280) + "." + string.substring(276, 278);
//            System.out.println("前16-17小时室内平均温度为：" + s44 + "℃");
//            BigDecimal bigDecimal17 = new BigDecimal(s44);
//            temperatureInfo.setSeventeenHeat(bigDecimal17);
//
//            String s45 = string.substring(280,282);
//            s45 = String.valueOf(Integer.parseInt(s45, 16));
//            System.out.println("前16-17小时湿度为：" + s45);
//            temperatureInfo.setSeventeenHumidity(s45);
//
//            String s46 = string.substring(288,290) + "." + string.substring(286, 288);
//            System.out.println("前17-18小时室内平均温度为：" + s46 + "℃");
//            BigDecimal bigDecimal18 = new BigDecimal(s46);
//            temperatureInfo.setEighteenHeat(bigDecimal18);
//
//            String s47 = string.substring(290,292);
//            s47 = String.valueOf(Integer.parseInt(s47, 16));
//            System.out.println("前17-18小时湿度为：" + s47);
//            temperatureInfo.setEighteenHumidity(s47);
//
//            String s48 = string.substring(298,300) + "." + string.substring(296, 298);
//            System.out.println("前18-19小时室内平均温度为：" + s48 + "℃");
//            BigDecimal bigDecimal19 = new BigDecimal(s48);
//            temperatureInfo.setNineteenHeata(bigDecimal19);
//
//            String s49 = string.substring(300,302);
//            s49 = String.valueOf(Integer.parseInt(s49, 16));
//            System.out.println("前18-19小时湿度为：" + s49);
//            temperatureInfo.setNineteenHumidity(s49);
//
//            String s50 = string.substring(308,310) + "." + string.substring(306, 308);
//            System.out.println("前19-20小时室内平均温度为：" + s50 + "℃");
//            BigDecimal bigDecimal20 = new BigDecimal(s50);
//            temperatureInfo.setTwentyHeat(bigDecimal20);
//
//            String s51 = string.substring(310,312);
//            s51 = String.valueOf(Integer.parseInt(s51, 16));
//            System.out.println("前19-20小时湿度为：" + s51);
//            temperatureInfo.setTwentyHumidity(s51);
//
//            String s52 = string.substring(318,320) + "." + string.substring(316, 318);
//            System.out.println("前20-21小时室内平均温度为：" + s52 + "℃");
//            BigDecimal bigDecimal21 = new BigDecimal(s52);
//            temperatureInfo.setTwentyOneHeat(bigDecimal21);
//
//            String s53 = string.substring(320,322);
//            s53 = String.valueOf(Integer.parseInt(s53, 16));
//            System.out.println("前20-21小时湿度为：" + s53);
//            temperatureInfo.setTwentyOneHumidity(s53);
//
//            String s54 = string.substring(328,330) + "." + string.substring(326, 328);
//            System.out.println("前21-22小时室内平均温度为：" + s54 + "℃");
//            BigDecimal bigDecimal22 = new BigDecimal(s54);
//            temperatureInfo.setTwentyTwoHeat(bigDecimal22);
//
//            String s55 = string.substring(330,332);
//            s55 = String.valueOf(Integer.parseInt(s55, 16));
//            System.out.println("前21-22小时湿度为：" + s55);
//            temperatureInfo.setTwentyTwoHumidity(s55);
//
//            String s56 = string.substring(338,340) + "." + string.substring(336, 338);
//            System.out.println("前22-23小时室内平均温度为：" + s56 + "℃");
//            BigDecimal bigDecimal23 = new BigDecimal(s56);
//            temperatureInfo.setTwentyThreeHeat(bigDecimal23);
//
//            String s57 = string.substring(340,342);
//            s57 = String.valueOf(Integer.parseInt(s57, 16));
//            System.out.println("前22-23小时湿度为：" + s57);
//            temperatureInfo.setTwentyThreeHumidity(s57);
//
//            String s58 = string.substring(348,350) + "." + string.substring(346, 348);
//            System.out.println("前23-24小时室内平均温度为：" + s58 + "℃");
//            BigDecimal bigDecimal24 = new BigDecimal(s58);
//            temperatureInfo.setTwentyFourHeat(bigDecimal24);
//
//            String s59 = string.substring(350,352);
//            s59 = String.valueOf(Integer.parseInt(s59, 16));
//            System.out.println("前23-24小时湿度为：" + s59);
//            temperatureInfo.setTwentyFourHumidity(s59);
//
////            String s60 = string.substring(358,360) + "." + string.substring(356, 358);
////            System.out.println("前1日0-24小时室内平均温度为：" + s60 + "℃");
////            BigDecimal bigDecimal25 = new BigDecimal(s60);
////            temperatureInfo.setDayHeat(bigDecimal25);
//
//            String s61 = string.substring(360,362);
//            s61 = String.valueOf(Integer.parseInt(s61, 16));
//            System.out.println("前1日0-24小时平均湿度为：" + s61);
//            temperatureInfo.setDayHumidity(s61);
//
//            String s62 = string.substring(364, 366) + string.substring(362, 364);
//            s62=String.valueOf(Integer.parseInt(s62, 16));
//            System.out.println("上报时间间隔（分钟）为："+s62+"分钟");
//            temperatureInfo.setReportingInterval(s62);
//
//            String s63 = string.substring(368, 370) + string.substring(366, 368);
//            s63=String.valueOf(Integer.parseInt(s63, 16));
//            System.out.println("上传延时（分钟）为："+s63+"分钟");
//            temperatureInfo.setUploadBranch(s63);
//
//            String s64 = string.substring(370, 372);
//            s64=String.valueOf(Integer.parseInt(s64, 16));
//            System.out.println("上传延时（秒）为："+s64+"秒");
//            temperatureInfo.setUploadSecond(s64);
//
//            String s65 = string.substring(378, 380)+string.substring(376,378);
//            s65=String.valueOf(Integer.parseInt(s65, 16));
//            System.out.println("上传总次数为："+s65+"次");
//            temperatureInfo.setUploadCount(s65);
//
//            String s66 = string.substring(382, 384)+string.substring(380,382);
//            s66=String.valueOf(Integer.parseInt(s66, 16));
//            System.out.println("成功次数为："+s66+"次");
//            temperatureInfo.setSuccesCount(s66);
//
//            String s67 = string.substring(386, 388)+string.substring(384,386);
//            s67=String.valueOf(Integer.parseInt(s67, 16));
//            int number = Integer.parseInt(s67);
//            double result = (double) number / 100;
//            s67=String .valueOf(result);
//            System.out.println("温度修正参数为："+s67);
//            temperatureInfo.setTemperatureCorrection(s67);
//
//            String s68 = string.substring(390, 392)+string.substring(388,390);
//            s68=String.valueOf(Integer.parseInt(s68, 16));
//            s68=String.valueOf(Integer.parseInt(s68, 16));
//            int num = Integer.parseInt(s68);
//            double res = (double) num / 100;
//            s68=String .valueOf(res);
//            System.out.println("湿度修正参数为："+s68);
//            temperatureInfo.setHumidityCorrection(s68);
//
//            String s69 = string.substring(392, 394);
//            System.out.println("数据有效性为："+s69);
//            temperatureInfo.setIsValid(s69);
//
//            String s70 = string.substring(394, 396);
//            s70=String.valueOf(Integer.parseInt(s70, 16));
//            System.out.println("信号强度为："+s70);
//            temperatureInfo.setSignals(s70);
//
//            String s71 = string.substring(396, 398);
//            System.out.println("运营商类型为："+s71);
//            temperatureInfo.setOperatorsType(s71);
//
//            String s72 = string.substring(416, 418)+string.substring(414,416)+string.substring(412,414)+string.substring(410,412)
//                    +string.substring(408,410)+string.substring(406,408)+string.substring(404,406)+string.substring(402,404)
//                    +string.substring(400,402)+string.substring(398,400);
//            System.out.println("SIM卡的ICCID为："+s72);
//            temperatureInfo.setICCID(s72);
//
//            String s73 = string.substring(436, 438)+string.substring(434,436)+string.substring(432,434)+string.substring(430,432)
//                    +string.substring(428,430)+string.substring(426,428)+string.substring(424,426)+string.substring(422,424)
//                    +string.substring(420,422)+string.substring(418,420);
//            s73=s73.replaceAll("^0+", "");
//            System.out.println("模组的IMEI为："+s73);
//            temperatureInfo.setIMEI(s73);
//
//            String s74=string.substring(440,442)+string.substring(438,440);
//            s74=String.valueOf(Integer.parseInt(s74, 16));
//            System.out.println("上传数据区块除去状态字的协议版本为："+s74);
//            temperatureInfo.setVersion(s74);
//
//            String s75=string.substring(444,446)+string.substring(442,444);
//            s75=String.valueOf(Integer.parseInt(s75, 16));
//            System.out.println("上传数据区块状态字的协议版本为："+s75);
//            temperatureInfo.setVersionState(s75);
//
//            String s76=string.substring(448,450)+string.substring(446,448);
//            s76=String.valueOf(Integer.parseInt(s76, 16));
//            int numbers = Integer.parseInt(s76);
//            s76 = String.format("%02d", numbers);
//            System.out.println("上传参数区块的类型为："+s76);
//            temperatureInfo.setType(s76);
//
//            String s77=string.substring(450,452)+string.substring(452,454);
//            System.out.println("上传参数区块的特征符号为："+s77);
//            temperatureInfo.setFeatures(s77);
//
//            String s78=string.substring(454,456);
//            s78=String.valueOf(Integer.parseInt(s78, 16));
//            System.out.println("上传参数区块的长度为："+s78+"u");
//            temperatureInfo.setLength(s78);

//            String s79=string.substring(456,458);
//            s79=String.valueOf(Integer.parseInt(s79, 16));
//            System.out.println("上传参数区块的校验码为："+s79);
//            temperatureInfo.setVerificationCode(s79);
            //将读取到的数据入库
//            temperatureInfoService.insertTemperatureInfo(temperatureInfo);
//        } catch (Exception e) {
//            e.printStackTrace();
//            System.err.println("Failed to parse JSON or decode Base64.");
//        }


        String s1 = string.substring(18, 20) + string.substring(16, 18) + string.substring(14, 16) + string.substring(12, 14) + string.substring(10, 12);
        System.out.println("仪表编号为：" + s1);
        temperatureInfo.setMeterCode(s1);

        String s3 = string.substring(22, 24) + string.substring(20, 22);
        System.out.println("厂家代码为：" + s3);
        temperatureInfo.setManufactorCode(s3);

        String s4 = string.substring(40, 42) + "." + string.substring(38, 40);
        if (string.charAt(40) == '0') {
            s4 = s4.substring(1, 5);
        }
        BigDecimal bigDecimalValue = new BigDecimal(s4);
        System.out.println("当前室内温度为：" + s4 + "℃");
        temperatureInfo.setTemperature(bigDecimalValue);

        String s5 = string.substring(44, 46) + "." + string.substring(42, 44);
        if (string.charAt(44) == '0') {
            s5 = s5.substring(1, 5);
        }
        System.out.println("电池电压为：" + s5);
        BigDecimal bigDecimal = new BigDecimal(s5);
        temperatureInfo.setVoltage(bigDecimal);

        String s6 = string.substring(52, 54) + "." + string.substring(50, 52);
        if (string.charAt(52) == '0') {
            s6 = s6.substring(1, 5);
        }
        System.out.println("当前室内温度(重复)为：" + s6 + "℃");
        BigDecimal bigDecimal1 = new BigDecimal(s6);
        temperatureInfo.setTemperature1(bigDecimal1);

        String s7 = string.substring(68, 70) + string.substring(66, 68) + string.substring(64, 66) + string.substring(62, 64);
        s7 = s7.replaceAll("^0+", "");
        System.out.println("累积上电时间为：" + s7 + "分钟");
        temperatureInfo.setPowerOn(s7);

        String s8 = string.substring(86, 88);
        s8 = String.valueOf(Integer.parseInt(s8, 16));
        System.out.println("当前室内湿度为：" + s8);
        temperatureInfo.setHumidity(s8);

        String s10 = string.substring(100, 102);
        s10 = s10.replaceAll("^0+", "");
        System.out.println("上一次信号强度为：" + s10);
        temperatureInfo.setSignalIntensity(s10);

        String s11 = string.substring(104, 106) + string.substring(102, 104);
        System.out.println("ST状态为：" + s11);
        temperatureInfo.setStState(s11);

        String s12 = string.substring(112, 114) + "." + string.substring(110, 112);
        System.out.println("前0-1小时室内平均温度为：" + s12 + "℃");
        BigDecimal decimal1 = new BigDecimal(s12);
        temperatureInfo.setOneHeat(decimal1);

        String s13 = string.substring(114, 116);
        s13 = String.valueOf(Integer.parseInt(s13, 16));
        System.out.println("前0-1小时湿度为：" + s13);
        temperatureInfo.setOneHumidity(s13);

        String s14 = string.substring(122, 124) + "." + string.substring(120, 122);
        System.out.println("前1-2小时室内平均温度为：" + s14 + "℃");
        BigDecimal bigDecimal2 = new BigDecimal(s14);
        temperatureInfo.setTwoHeat(bigDecimal2);

        String s15 = string.substring(124, 126);
        s15 = String.valueOf(Integer.parseInt(s15, 16));
        System.out.println("前1-2小时湿度为：" + s15);
        temperatureInfo.setTwoHumidity(s15);

        String s16 = string.substring(132, 134) + "." + string.substring(130, 132);
        System.out.println("前2-3小时室内平均温度为：" + s16 + "℃");
        BigDecimal bigDecimal3 = new BigDecimal(s16);
        temperatureInfo.setThreeHeat(bigDecimal3);

        String s17 = string.substring(136, 138);
        s17 = String.valueOf(Integer.parseInt(s17, 16));
        System.out.println("前2-3小时湿度为：" + s17);
        temperatureInfo.setThreeHumidity(s17);

        String s18 = string.substring(142, 144) + "." + string.substring(140, 142);
        System.out.println("前3-4小时室内平均温度为：" + s18 + "℃");
        BigDecimal bigDecimal4 = new BigDecimal(s18);
        temperatureInfo.setFourHeat(bigDecimal4);

        String s19 = string.substring(144, 146);
        s19 = String.valueOf(Integer.parseInt(s19, 16));
        System.out.println("前3-4小时湿度为：" + s19);
        temperatureInfo.setFourHumidity(s19);

        String s20 = string.substring(152, 154) + "." + string.substring(150, 152);
        System.out.println("前4-5小时室内平均温度为：" + s20 + "℃");
        BigDecimal bigDecimal5 = new BigDecimal(s20);
        temperatureInfo.setFiveHeat(bigDecimal5);

        String s21 = string.substring(154, 156);
        s21 = String.valueOf(Integer.parseInt(s21, 16));
        System.out.println("前4-5小时湿度为：" + s21);
        temperatureInfo.setFiveHumidity(s21);

        String s22 = string.substring(162, 164) + "." + string.substring(160, 162);
        System.out.println("前5-6小时室内平均温度为：" + s22 + "℃");
        BigDecimal bigDecimal6 = new BigDecimal(s22);
        temperatureInfo.setSixHeat(bigDecimal6);

        String s23 = string.substring(164, 166);
        s23 = String.valueOf(Integer.parseInt(s23, 16));
        System.out.println("前5-6小时湿度为：" + s23);
        temperatureInfo.setSixHumidity(s23);

        String s24 = string.substring(172, 174) + "." + string.substring(170, 172);
        System.out.println("前6-7小时室内平均温度为：" + s24 + "℃");
        BigDecimal bigDecimal7 = new BigDecimal(s24);
        temperatureInfo.setSevenHeat(bigDecimal7);

        String s25 = string.substring(174, 176);
        s25 = String.valueOf(Integer.parseInt(s25, 16));
        System.out.println("前6-7小时湿度为：" + s25);
        temperatureInfo.setSevenHumidity(s25);

        String s26 = string.substring(182, 184) + "." + string.substring(180, 182);
        System.out.println("前7-8小时室内平均温度为：" + s26 + "℃");
        BigDecimal bigDecimal8 = new BigDecimal(s26);
        temperatureInfo.setEightHeat(bigDecimal8);

        String s27 = string.substring(184, 186);
        s27 = String.valueOf(Integer.parseInt(s27, 16));
        System.out.println("前7-8小时湿度为：" + s27);
        temperatureInfo.setEightHumidity(s27);

        String s28 = string.substring(192, 194) + "." + string.substring(190, 192);
        System.out.println("前8-9小时室内平均温度为：" + s28 + "℃");
        BigDecimal bigDecimal9 = new BigDecimal(s28);
        temperatureInfo.setNineHeat(bigDecimal9);

        String s29 = string.substring(194, 196);
        s29 = String.valueOf(Integer.parseInt(s29, 16));
        System.out.println("前8-9小时湿度为：" + s29);
        temperatureInfo.setNineHumidity(s29);

        String s30 = string.substring(202, 204) + "." + string.substring(200, 202);
        System.out.println("前9-10小时室内平均温度为：" + s30 + "℃");
        BigDecimal bigDecimal10 = new BigDecimal(s30);
        temperatureInfo.setTenHeat(bigDecimal10);

        String s31 = string.substring(204, 206);
        s31 = String.valueOf(Integer.parseInt(s31, 16));
        System.out.println("前9-10小时湿度为：" + s31);
        temperatureInfo.setTenHumidity(s31);

        String s32 = string.substring(212, 214) + "." + string.substring(210, 212);
        System.out.println("前10-11小时室内平均温度为：" + s32 + "℃");
        BigDecimal bigDecimal11 = new BigDecimal(s32);
        temperatureInfo.setElevenHeat(bigDecimal11);

        String s33 = string.substring(214, 216);
        s33 = String.valueOf(Integer.parseInt(s33, 16));
        System.out.println("前10-11小时湿度为：" + s33);
        temperatureInfo.setElevenHumidity(s33);

        String s34 = string.substring(222, 224) + "." + string.substring(220, 222);
        System.out.println("前11-12小时室内平均温度为：" + s34 + "℃");
        BigDecimal bigDecimal12 = new BigDecimal(s34);
        temperatureInfo.setTwelveHeat(bigDecimal12);

        String s35 = string.substring(224, 226);
        s35 = String.valueOf(Integer.parseInt(s35, 16));
        System.out.println("前11-12小时湿度为：" + s35);
        temperatureInfo.setTwelveHumidity(s35);

        String s36 = string.substring(232, 234) + "." + string.substring(230, 232);
        System.out.println("前12-13小时室内平均温度为：" + s36 + "℃");
        BigDecimal bigDecimal13 = new BigDecimal(s36);
        temperatureInfo.setThirteenHeat(bigDecimal13);

        String s37 = string.substring(234, 236);
        s37 = String.valueOf(Integer.parseInt(s37, 16));
        System.out.println("前12-13小时湿度为：" + s37);
        temperatureInfo.setThirteenHumidity(s37);

        String s38 = string.substring(242, 244) + "." + string.substring(240, 242);
        System.out.println("前13-14小时室内平均温度为：" + s38 + "℃");
        BigDecimal bigDecimal14 = new BigDecimal(s38);
        temperatureInfo.setFourteenHeat(bigDecimal14);

        String s39 = string.substring(244, 246);
        s39 = String.valueOf(Integer.parseInt(s39, 16));
        System.out.println("前13-14小时湿度为：" + s39);
        temperatureInfo.setFourteenHumidity(s39);

        String s40 = string.substring(252, 254) + "." + string.substring(250, 252);
        System.out.println("前14-15小时室内平均温度为：" + s40 + "℃");
        BigDecimal bigDecimal15 = new BigDecimal(s40);
        temperatureInfo.setFifteenHeat(bigDecimal15);

        String s41 = string.substring(254, 256);
        s41 = String.valueOf(Integer.parseInt(s41, 16));
        System.out.println("前14-15小时湿度为：" + s41);
        temperatureInfo.setFifteenHumidity(s41);

        String s42 = string.substring(262, 264) + "." + string.substring(260, 262);
        System.out.println("前15-16小时室内平均温度为：" + s42 + "℃");
        BigDecimal bigDecimal16 = new BigDecimal(s42);
        temperatureInfo.setSixteenHeat(bigDecimal16);

        String s43 = string.substring(264, 266);
        s43 = String.valueOf(Integer.parseInt(s43, 16));
        System.out.println("前15-16小时湿度为：" + s43);
        temperatureInfo.setSixteenHumidity(s43);

        String s44 = string.substring(272, 274) + "." + string.substring(270, 272);
        System.out.println("前16-17小时室内平均温度为：" + s44 + "℃");
        BigDecimal bigDecimal17 = new BigDecimal(s44);
        temperatureInfo.setSeventeenHeat(bigDecimal17);

        String s45 = string.substring(274, 276);
        s45 = String.valueOf(Integer.parseInt(s45, 16));
        System.out.println("前16-17小时湿度为：" + s45);
        temperatureInfo.setSeventeenHumidity(s45);

        String s46 = string.substring(282, 284) + "." + string.substring(280, 282);
        System.out.println("前17-18小时室内平均温度为：" + s46 + "℃");
        BigDecimal bigDecimal18 = new BigDecimal(s46);
        temperatureInfo.setEighteenHeat(bigDecimal18);

        String s47 = string.substring(284, 286);
        s47 = String.valueOf(Integer.parseInt(s47, 16));
        System.out.println("前17-18小时湿度为：" + s47);
        temperatureInfo.setEighteenHumidity(s47);

        String s48 = string.substring(292, 294) + "." + string.substring(290, 292);
        System.out.println("前18-19小时室内平均温度为：" + s48 + "℃");
        BigDecimal bigDecimal19 = new BigDecimal(s48);
        temperatureInfo.setNineteenHeata(bigDecimal19);

        String s49 = string.substring(294, 296);
        s49 = String.valueOf(Integer.parseInt(s49, 16));
        System.out.println("前18-19小时湿度为：" + s49);
        temperatureInfo.setNineteenHumidity(s49);

        String s50 = string.substring(302, 304) + "." + string.substring(300, 302);
        System.out.println("前19-20小时室内平均温度为：" + s50 + "℃");
        BigDecimal bigDecimal20 = new BigDecimal(s50);
        temperatureInfo.setTwentyHeat(bigDecimal20);

        String s51 = string.substring(304, 306);
        s51 = String.valueOf(Integer.parseInt(s51, 16));
        System.out.println("前19-20小时湿度为：" + s51);
        temperatureInfo.setTwentyHumidity(s51);

        String s52 = string.substring(312, 314) + "." + string.substring(310, 312);
        System.out.println("前20-21小时室内平均温度为：" + s52 + "℃");
        BigDecimal bigDecimal21 = new BigDecimal(s52);
        temperatureInfo.setTwentyOneHeat(bigDecimal21);

        String s53 = string.substring(314, 316);
        s53 = String.valueOf(Integer.parseInt(s53, 16));
        System.out.println("前20-21小时湿度为：" + s53);
        temperatureInfo.setTwentyOneHumidity(s53);

        String s54 = string.substring(322, 324) + "." + string.substring(320, 322);
        System.out.println("前21-22小时室内平均温度为：" + s54 + "℃");
        BigDecimal bigDecimal22 = new BigDecimal(s54);
        temperatureInfo.setTwentyTwoHeat(bigDecimal22);

        String s55 = string.substring(324, 326);
        s55 = String.valueOf(Integer.parseInt(s55, 16));
        System.out.println("前21-22小时湿度为：" + s55);
        temperatureInfo.setTwentyTwoHumidity(s55);

        String s56 = string.substring(332, 334) + "." + string.substring(330, 332);
        System.out.println("前22-23小时室内平均温度为：" + s56 + "℃");
        BigDecimal bigDecimal23 = new BigDecimal(s56);
        temperatureInfo.setTwentyThreeHeat(bigDecimal23);

        String s57 = string.substring(334, 336);
        s57 = String.valueOf(Integer.parseInt(s57, 16));
        System.out.println("前22-23小时湿度为：" + s57);
        temperatureInfo.setTwentyThreeHumidity(s57);

        String s58 = string.substring(342, 344) + "." + string.substring(340, 342);
        System.out.println("前23-24小时室内平均温度为：" + s58 + "℃");
        BigDecimal bigDecimal24 = new BigDecimal(s58);
        temperatureInfo.setTwentyFourHeat(bigDecimal24);

        String s59 = string.substring(344, 346);
        s59 = String.valueOf(Integer.parseInt(s59, 16));
        System.out.println("前23-24小时湿度为：" + s59);
        temperatureInfo.setTwentyFourHumidity(s59);

        String s61 = string.substring(354, 356);
        s61 = String.valueOf(Integer.parseInt(s61, 16));
        System.out.println("前1日0-24小时平均湿度为：" + s61);
        temperatureInfo.setDayHumidity(s61);

        String s62 = string.substring(358, 360) + string.substring(356, 358);
        s62 = String.valueOf(Integer.parseInt(s62, 16));
        System.out.println("上报时间间隔（分钟）为：" + s62 + "分钟");
        temperatureInfo.setReportingInterval(s62);

        String s63 = string.substring(362, 364) + string.substring(360, 362);
        s63 = String.valueOf(Integer.parseInt(s63, 16));
        System.out.println("上传延时（分钟）为：" + s63 + "分钟");
        temperatureInfo.setUploadBranch(s63);

        String s64 = string.substring(366, 368);
        s64 = String.valueOf(Integer.parseInt(s64, 16));
        System.out.println("上传延时（秒）为：" + s64 + "秒");
        temperatureInfo.setUploadSecond(s64);

        String s65 = string.substring(372, 374) + string.substring(370, 372);
        s65 = String.valueOf(Integer.parseInt(s65, 16));
        System.out.println("上传总次数为：" + s65 + "次");
        temperatureInfo.setUploadCount(s65);

        String s66 = string.substring(376, 378) + string.substring(374, 376);
        s66 = String.valueOf(Integer.parseInt(s66, 16));
        System.out.println("成功次数为：" + s66 + "次");
        temperatureInfo.setSuccesCount(s66);

        String s67 = string.substring(380, 382) + string.substring(378, 380);
        s67 = String.valueOf(Integer.parseInt(s67, 16));
        int number = Integer.parseInt(s67);
        double result = (double) number / 100;
        s67 = String.valueOf(result);
        System.out.println("温度修正参数为：" + s67);
        temperatureInfo.setTemperatureCorrection(s67);

        String s68 = string.substring(384, 386) + string.substring(382, 384);
        s68 = String.valueOf(Integer.parseInt(s68, 16));
        s68 = String.valueOf(Integer.parseInt(s68, 16));
        int num = Integer.parseInt(s68);
        double res = (double) num / 100;
        s68 = String.valueOf(res);
        System.out.println("湿度修正参数为：" + s68);
        temperatureInfo.setHumidityCorrection(s68);

        String s69 = string.substring(386, 388);
        System.out.println("数据有效性为：" + s69);
        temperatureInfo.setIsValid(s69);

        String s70 = string.substring(388, 390);
        s70 = String.valueOf(Integer.parseInt(s70, 16));
        System.out.println("信号强度为：" + s70);
        temperatureInfo.setSignals(s70);

        String s71 = string.substring(390, 392);
        System.out.println("运营商类型为：" + s71);
        temperatureInfo.setOperatorsType(s71);

        String s72 = string.substring(410, 412) + string.substring(408, 410) + string.substring(406, 408) + string.substring(404, 406) + string.substring(402, 404) + string.substring(400, 402) + string.substring(398, 400) + string.substring(396, 398);
        System.out.println("SIM卡的ICCID为：" + s72);
        temperatureInfo.setICCID(s72);

        String s73 = string.substring(430, 432) + string.substring(428, 430) + string.substring(426, 428) + string.substring(424, 426) + string.substring(422, 424) + string.substring(420, 422) + string.substring(418, 420);
        s73 = s73.replaceAll("^0+", "");
        System.out.println("模组的IMEI为：" + s73);
        temperatureInfo.setIMEI(s73);

        String s74 = string.substring(434, 436) + string.substring(432, 434);
        s74 = String.valueOf(Integer.parseInt(s74, 16));
        System.out.println("上传数据区块除去状态字的协议版本为：" + s74);
        temperatureInfo.setVersion(s74);

        String s75 = string.substring(438, 440) + string.substring(436, 438);
        s75 = String.valueOf(Integer.parseInt(s75, 16));
        System.out.println("上传数据区块状态字的协议版本为：" + s75);
        temperatureInfo.setVersionState(s75);

        String s76 = string.substring(442, 444) + string.substring(440, 442);
        s76 = String.valueOf(Integer.parseInt(s76, 16));
        int numbers = Integer.parseInt(s76);
        s76 = String.format("%02d", numbers);
        System.out.println("上传参数区块的类型为：" + s76);
        temperatureInfo.setType(s76);

        String s77 = string.substring(446, 448) + string.substring(444, 446);
        System.out.println("上传参数区块的特征符号为：" + s77);
        temperatureInfo.setFeatures(s77);

        String s78 = string.substring(450, 452);
        s78 = String.valueOf(Integer.parseInt(s78, 16));
        System.out.println("上传参数区块的长度为：" + s78 + "u");
        temperatureInfo.setLength(s78);





        // TODO: 你可以在这里解析payload并进行实际的业务处理，如保存到数据库等
    }


}

